package com.lsh;

import com.lsh.exception.DelFastDFSFileException;
import com.lsh.unit.ResultObject;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理类
 */
@ControllerAdvice
public class BaseExceptionHandler {

    @ExceptionHandler(value = ArrayIndexOutOfBoundsException.class)
    @ResponseBody
    public ResultObject error(ArrayIndexOutOfBoundsException e){
        e.printStackTrace();
        return new ResultObject("500", "请选择上传文件", e.getMessage());
    }
    @ExceptionHandler(value = DelFastDFSFileException.class)
    @ResponseBody
    public ResultObject error2(DelFastDFSFileException e){
        e.printStackTrace();
        return new ResultObject("501", "文件删除失败", e.getMessage());
    }
}



